#include "dtrangedialog.h"
#include "ui_dtrangedialog.h"

#include <QPushButton>

DTRangeDialog::DTRangeDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::DTRangeDialog)
{
    ui->setupUi(this);

    connect(ui->startRange, SIGNAL(toggled(bool)), ui->startDate, SLOT(setEnabled(bool)));
    connect(ui->startRange, SIGNAL(toggled(bool)), ui->startTime, SLOT(setEnabled(bool)));
    connect(ui->endRange, SIGNAL(toggled(bool)), ui->endDate, SLOT(setEnabled(bool)));
    connect(ui->endRange, SIGNAL(toggled(bool)), ui->endTime, SLOT(setEnabled(bool)));

    ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("OK"));
    ui->buttonBox->button(QDialogButtonBox::Cancel)->setText(tr("Cancel"));
}

DTRangeDialog::~DTRangeDialog()
{
    delete ui;
}

void DTRangeDialog::disableRangeStart()
{
    ui->startRange->setChecked(false);
}

void DTRangeDialog::disableRangeEnd()
{
    ui->endRange->setChecked(false);
}

void DTRangeDialog::disableDate()
{
    ui->startDate->setVisible(false);
    ui->endDate->setVisible(false);
}

void DTRangeDialog::setStartDate(const QDate &date)
{
    ui->startDate->setDate(date);
}

void DTRangeDialog::setStartTime(const QTime &time)
{
    ui->startTime->setTime(time);
}

void DTRangeDialog::setEndDate(const QDate &date)
{
    ui->endDate->setDate(date);
}

void DTRangeDialog::setEndTime(const QTime &time)
{
    ui->endTime->setTime(time);
}

QDate DTRangeDialog::startDate()
{
    return ui->startDate->date();
}

QTime DTRangeDialog::startTime()
{
    return ui->startTime->time();
}

QDate DTRangeDialog::endDate()
{
    return ui->endDate->date();
}

QTime DTRangeDialog::endTime()
{
    return ui->endTime->time();
}

bool DTRangeDialog::hasBegin()
{
    return ui->startRange->isChecked();
}

bool DTRangeDialog::hasEnd()
{
    return ui->endRange->isChecked();
}
